import time
from selenium import webdriver

# 获取url
url = 'https://www.baidu.com/'

# 创建driver对象
driver = webdriver.Chrome(executable_path=r'E:\ChromeDriver\chromedriver_win32/chromedriver.exe')

# 发送请求
driver.get(url)

# 展示页面源代码
print(driver)

# 展示当前页的url
print(driver.current_url)

# 对当前页面进行截图
# 截图常用于验证码的识别
driver.save_screenshot('baidu.png')

# 打开豆瓣
driver.get('https://www.douban.com')
time.sleep(2)

# 后退
driver.back()
time.sleep(2)

# 前进
driver.forward()
time.sleep(2)

# 关闭当前页
driver.close()
time.sleep(2)

# 关闭浏览器
driver.quit()

